package com.epam.parser;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

public class Text extends ArrayList<TextPart> {
	
	public static Logger log = Logger.getLogger(Text.class.getName());
	private static final long serialVersionUID = 1L;

	public Text(List<TextPart> textparts) {
		for (TextPart part : textparts) {
			this.add(part);
		}

	}

	public Text() {
	}

	public Text(String s) {
		this.add(new TextPart(s));
	}

	public static Text readTextFromFile(String fileName) throws IOException {
		Text t = new Text();
		BufferedReader b = new BufferedReader(new FileReader(fileName));
		String s;
		while ((s = b.readLine()) != null) {
			t.add(new TextPart(s));
			}
		b.close();
		return t;

	}
}